'''
Author: duliang thinktanker@163.com
Date: 2023-06-21 21:46:46
LastEditors: duliang thinktanker@163.com
LastEditTime: 2024-06-24 20:11:53
FilePath: \sajj\testspeed.py
Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
'''
import time
from sql import get_equal_rate


def get_maxRatio_title(test_title):
    maxRatio = 0
    maxTitle = ''
    # index = 0
    # now = time.time()
    for title in titleList:
        ratio = get_equal_rate(test_title, title)
        # print(ratio)
        if maxRatio < ratio:
            maxRatio = ratio
            maxTitle = title
    # print('for 用时',time.time()-now)
    # now = time.time()
    # while index <titleCount:
    #     ratio = get_equal_rate(test_title, titleList[index])
    #     # print(ratio)
    #     if maxRatio < ratio:
    #         maxRatio = ratio
    #         maxTitle = titleList[index]
    #     index+=1
    # print('while 用时',time.time()-now)
    # print('匹配率：{} 题干：{}'.format(maxRatio, maxTitle))
    return maxTitle.replace('\n', '')


titleList = []
with open('title.txt', 'r', encoding='utf8') as f:
    titleList = f.readlines()

import time

now = time.time()
get_maxRatio_title(
    '火灾探测器的工作原理是将烟雾、温度、火焰和燃烧气体导参量的变化通过敏感元件转化为电信号，传输到大灾报警控制器，不同种类的火灾探测器适用不同的场合。关于火灾探测器适用场合的说法，正确的是（ ）。'
)
print(time.time() - now)
